% 参数设置
fs = 1000; % 采样频率，单位Hz
T = 1; % 信号周期，单位秒
t = 0:1/fs:T; % 时间向量
data = [0, 1, 0, 1, 1, 0]; % 待传输的二进制数据序列
pulse_width = 0.1; % 脉冲宽度，单位秒
slot_width = T/length(data); % 每个数据位的时隙宽度

% 生成PPM信号
ppm_signal = zeros(1, length(t));
for i = 1:length(data)
    if data(i) == 1
        start_time = (i-1)*slot_width + pulse_width/2;
        end_time = start_time + pulse_width;
        ppm_signal(t >= start_time & t < end_time) = 1;
    end
end

% 绘制PPM信号图像
figure;
plot(t, ppm_signal);
title('PPM Signal');
xlabel('Time (s)');
ylabel('Amplitude');

grid on;
%111111
plot(t);
%999
%777
%444

